<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<script id="test3" type="text/html">
    <p><a href="#">{{name}}：</a><span>{{country}}</span></p>
    {{#list names as p}}
        <p><a href="#">{{p.name}}：</a><span>{{p.country}}</span></p>
    {{/#list}}
</script>
<div id="comment_ul_2"></div>
<input type="button" value="click me" onclick="add()"/>
<script type="text/javascript">
    var reg1 = new RegExp("{{([^#|\/].*?)}}", 'igm');
    var reg2 = new RegExp("{{#list.*?}}(.*?){{/#list}}");
    var names = [
        {name: 'Jani', country: 'Norway'},
        {name: 'Hege', country: 'Sweden'},
        {name: 'Kai', country: 'Denmark'}];
    function add() {
        var html = document.getElementById("test3").innerHTML;
        var source = html.replace(reg1, function (node, key) {
            return names[0][key];
        });
        document.getElementById('comment_ul_2').innerHTML = source;
    }
</script>
</body>
</html>